package com.buss.check.model;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import org.codehaus.jackson.annotate.JsonIgnoreProperties;

import com.buss.check.dic.CheckObj;
import com.buss.core.model.Organization;
import com.buss.core.model.User;

@Entity
@Table(name="check_flow")
@TableGenerator(name="checkflow_pk_sequence",initialValue=1,allocationSize=1,pkColumnName="seq_col",
	pkColumnValue="checkflow_seq",valueColumnName="seq_val",table="core_pk_sequence")
@JsonIgnoreProperties(value={"organs","users"})
public class CheckFlow implements Serializable {

	private static final long serialVersionUID = -6047694260390521695L;

	/**审核流程主键*/
	@Id
	@GeneratedValue(strategy=GenerationType.TABLE,generator="checkflow_pk_sequence")
	private Long id;
	
	/**审核对象 */
	@Column(nullable=false,length=20)
	@Enumerated(EnumType.STRING)
	private CheckObj checkObj;
	
	/**单位编码*/
	@Column(nullable=false,length=20)
	private String companyId;
	
	/**审核流程名称*/
	private String name;
	
	/**流程(流程用数字记录)*/
	private int flow;
	
	/**审核组织机构*/
	@ManyToMany(cascade=CascadeType.REFRESH,fetch=FetchType.LAZY)
	@JoinTable(name="check_checkflow_organ",inverseJoinColumns=@JoinColumn(name="organId",updatable=false),
			joinColumns=@JoinColumn(name="flowId",updatable=false))	
	private List<Organization> organs;
	
	/**审核人*/
	@ManyToMany(cascade=CascadeType.REFRESH,fetch=FetchType.LAZY)
	@JoinTable(name="check_checkflow_user",inverseJoinColumns=@JoinColumn(name="userId",updatable=false),
			joinColumns=@JoinColumn(name="flowId",updatable=false))
	private List<User> users;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public CheckObj getCheckObj() {
		return checkObj;
	}

	public void setCheckObj(CheckObj checkObj) {
		this.checkObj = checkObj;
	}

	public String getCompanyId() {
		return companyId;
	}

	public void setCompanyId(String companyId) {
		this.companyId = companyId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<Organization> getOrgans() {
		return organs;
	}

	public void setOrgans(List<Organization> organs) {
		this.organs = organs;
	}

	public List<User> getUsers() {
		return users;
	}

	public void setUsers(List<User> users) {
		this.users = users;
	}

	public int getFlow() {
		return flow;
	}

	public void setFlow(int flow) {
		this.flow = flow;
	}
	
	
}
